<template>
  <h1>计算器练习</h1>
  <input type="text" placeholder="请输入数字" v-model="num1"><br>
  <input type="text" placeholder="请输入数字" v-model="num2"><br>
  <button @click="calc('+')">加</button>
  <button @click="calc('-')">减</button>
  <button @click="calc('*')">乘</button>
  <button @click="calc('/')">除</button>
  <p>结果：{{result}}</p>
</template>

<script setup>
import {ref} from "vue";

const num1 = ref('');
const num2 = ref('');
const result = ref('');

const calc=(o)=>{
  result.value = eval(num1.value+o+num2.value);
}

</script>

<style scoped>

</style>